import {
  BaseInfoType,
  EventInfo,
  MenuToConfigMappingType,
} from "../../../framework/core/AbstractDefinition";
import { ClazzTemplate } from "../../common-component/CommonTypes";
import { MenuInfo } from "../../../designer/right/MenuType";
import IotTempHumImg from "./data-temp-hum.png";
import { IotTempHumController } from "./IotTempHumController";
import { IotTempHumComponentProps } from "./IotTempHumComponent";
import { IotTempHumStyleConfig } from "./IotTempHumConfig";
import React from "react";
import AbstractDesignerDefinition from "../../../framework/core/AbstractDesignerDefinition";
import { IotTempHumDeviceConfig } from "./IotTempHumDeviceConfig";

const BaseInfo = React.lazy(
  () => import("../../common-component/base-info/BaseInfo")
);
const ThemeConfig = React.lazy(
  () => import("../../common-component/theme-config/ThemeConfig")
);
const AnimationConfig = React.lazy(
  () => import("../../common-component/animation-config/AnimationConfig")
);
const FilterConfig = React.lazy(
  () => import("../../common-component/filter-config/FilterConfig")
);

export default class IotTempHumDefinition extends AbstractDesignerDefinition<
  IotTempHumController,
  IotTempHumComponentProps
> {
  getBaseInfo(): BaseInfoType {
    return {
      compName: "环境温湿度",
      compKey: "IotTempHum",
      categorize: "data",
      width: 170,
      height: 60,
      code: 112, // 温湿度产品固定编码
    };
  }

  getChartImg(): string | null {
    return IotTempHumImg;
  }

  getController(): ClazzTemplate<IotTempHumController> | null {
    return IotTempHumController;
  }

  getInitConfig(): IotTempHumComponentProps {
    return {
      base: {
        id: "",
        name: "环境温湿度",
        type: "IotTempHum",
        code: 112, // 温湿度产品固定编码
      },
      style: {
        color: "#a7a7a7",
        fontSize: 16,
        alignItems: "center",
        justifyContent: "center",
        borderColor: "#2772C9",
        borderRadius: 10,
      },
      filter: {
        enable: false,
        blur: 0,
        brightness: 1,
        contrast: 1,
        opacity: 1,
        saturate: 1,
        hueRotate: 0,
      },
      device: {
        terminalId: "",
        deviceCode: "",
        position: "",
      },
      data: {
        sourceType: "static",
        staticData: "环境温湿度",
      },
    };
  }

  getMenuList(): Array<MenuInfo> {
    return super
      .getMenuList()
      .filter(
        (item: MenuInfo) =>
          item.key !== "theme" &&
          item.key !== "data" &&
          item.key !== "filter" &&
          item.key !== "base"
      );
  }

  getMenuToConfigContentMap(): MenuToConfigMappingType {
    return {
      base: BaseInfo,
      style: IotTempHumStyleConfig,
      animation: AnimationConfig,
      theme: ThemeConfig,
      filter: FilterConfig,
      device: IotTempHumDeviceConfig,
    };
  }

  getEventList(): EventInfo[] {
    const events = super.getEventList();
    return events.concat([
      {
        id: "click",
        name: "点击时",
      },
    ]);
  }
}
